Software in a computer system is made up of many layers. The highest layer is typically referred to as the application layer, followed by lower layers that include the operating system, device drivers (which usually are a part of the operating system), and other layers. In a system that is coupled to a network, various network and transport layers are typically also present.
Conventionally, in an operating system, a software program is run as one or more execution entities, such as threads, processes, and so forth. For example, in some Unix operating systems, a process is defined as the execution of a program. The operating system schedules multiple processes for execution, with concurrently scheduled processes appearing to execute simultaneously. A scheduler in the operating system schedules a period of time (sometimes referred to as a time slice or time quantum) for each process, using a priority scheme to determine which process to schedule next.
In other Unix operating systems, execution entities are threads associated with processes or programs. Each process has an execution context that is unique to the process, with each process associated with an address space, a set of resources accessible by the process, and a set of one or more threads that belong to the process. Each process has at least one thread that is created and that belongs to the process, although a process can have multiple threads that belong to it.
Because multiple threads (either associated with a single process or with multiple processes) can be active at a given time, a synchronization mechanism is desirable. However, conventional synchronization mechanisms based on low-level primitives such as mutexes and condition variables in Unix systems may not provide a desired level of flexibility.